home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / opussdk / include / dopus / modules.h < prev    next >
C/C++ Source or Header  |  1996-09-05  |  7KB  |  238 lines

  1. #ifndef _DOPUS_MODULES
  2. #define _DOPUS_MODULES
  3.  
  4. /****************************************************************************
  5.  
  6.  Support file for DOpus modules
  7.  
  8.  ****************************************************************************/
  9.  
  10. #ifndef _DOPUSBASE
  11. #include <dopus/dopusbase.h>
  12. #endif
  13.  
  14.  
  15. // Defines a function in a module
  16. typedef struct
  17. {
  18.     ULONG    id;        // Function ID code
  19.     char    *name;          // Function name
  20.     ULONG    desc;           // Locale string ID for function description
  21.     ULONG    flags;        // Function flags
  22.     char    *template;    // Command template
  23. } ModuleFunction;
  24.  
  25. // Function flags
  26. #define FUNCF_NEED_SOURCE        (1<<0)    // Needs a source directory
  27. #define FUNCF_NEED_DEST            (1<<1)    // Needs a destination directory
  28. #define FUNCF_NEED_FILES        (1<<2)    // Needs some files to work with
  29. #define FUNCF_NEED_DIRS            (1<<3)    // Needs some files to work with
  30. #define FUNCF_NEED_ENTRIES    (FUNCF_NEED_FILES|FUNCF_NEED_DIRS)
  31. #define FUNCF_CAN_DO_ICONS        (1<<6)    // Function can do icons
  32. #define FUNCF_SINGLE_SOURCE        (1<<8)    // Only a single source needed
  33. #define FUNCF_SINGLE_DEST        (1<<9)    // Only a single destination needed
  34. #define FUNCF_WANT_DEST            (1<<11)    // Want destinations, don't need them
  35. #define FUNCF_WANT_SOURCE        (1<<12)    // Want source, don't need it
  36. #define FUNCF_WANT_ENTRIES        (1<<19)    // Want entries
  37. #define FUNCF_PRIVATE            (1<<26) // Function is private
  38.  
  39.  
  40. // Defines all the functions in a module
  41. typedef struct
  42. {
  43.     ULONG        ver;        // Module version
  44.     char        *name;        // Module name
  45.     char        *locale_name;    // Catalog name
  46.     ULONG        flags;        // Module flags
  47.     ULONG        function_count;    // Number of functions in module
  48.     ModuleFunction    function[1];    // Definition of first function
  49. } ModuleInfo;
  50.  
  51.  
  52. /*** If the module has more than one function, the additional ModuleFunction
  53.      structures MUST follow the ModuleInfo structure in memory. Eg,
  54.  
  55.      ModuleInfo module_info={....};
  56.      ModuleFunction more_funcs[2]={{...},{...}};                           ***/
  57.  
  58.  
  59. // Flags for ModuleInfo
  60. #define MODULEF_CALL_STARTUP        (1<<0)    // Call ModuleEntry() on startup
  61. #define MODULEF_STARTUP_SYNC        (1<<1)    // Run Synchronously on startup
  62.  
  63. // ID passed to Module_Entry() if module is run on startup
  64. #define FUNCID_STARTUP            0xffffffff
  65.  
  66. // Callback commands
  67. #define EXTCMD_GET_SOURCE    0    // Get current source path
  68. #define EXTCMD_NEXT_SOURCE    1    // Get next source path
  69. #define EXTCMD_UNLOCK_SOURCE    2    // Unlock source paths
  70. #define EXTCMD_GET_ENTRY    3    // Get entry
  71. #define EXTCMD_END_ENTRY    4    // End entry
  72. #define EXTCMD_RELOAD_ENTRY    5    // Reload entry
  73. #define EXTCMD_CHECK_ABORT    9    // Check abort status
  74. #define EXTCMD_ENTRY_COUNT    10    // Get entry count
  75. #define EXTCMD_GET_WINDOW    11    // Get window handle
  76. #define EXTCMD_GET_DEST        12    // Get next destination
  77. #define EXTCMD_END_SOURCE    13    // Cleanup current source path
  78. #define EXTCMD_END_DEST        14    // Cleanup current destination path
  79. #define EXTCMD_ADD_FILE        16    // Add a file to a lister
  80. #define EXTCMD_GET_HELP        17    // Get help on a topic
  81. #define EXTCMD_GET_PORT        18    // Get ARexx port name
  82. #define EXTCMD_GET_SCREEN    19    // Get public screen name
  83. #define EXTCMD_REPLACE_REQ    20    // Show exists/replace? requester
  84. #define EXTCMD_REMOVE_ENTRY    21    // Mark an entry for removal
  85. #define EXTCMD_GET_SCREENDATA    22    // Get DOpus screen data
  86. #define EXTCMD_FREE_SCREENDATA    23    // Free screen data
  87. #define EXTCMD_SEND_COMMAND    30    // Send a command to DOpus
  88. #define EXTCMD_DEL_FILE        31    // Delete a file from a lister
  89. #define EXTCMD_DO_CHANGES    32    // Perform changes
  90. #define EXTCMD_LOAD_FILE    33    // Load files to listers
  91.  
  92.  
  93. // Structures used with callback commands
  94. struct function_entry
  95. {
  96.     ULONG            pad[2];
  97.     char            *name;    // File name
  98.     APTR            entry;    // Entry pointer (don't touch!)
  99.     short            type;    // Type of file
  100.     short            flags;    // File flags
  101. };
  102.  
  103. struct path_node
  104. {
  105.     ULONG            pad[2];
  106.     char            buffer[512];    // Contains path string
  107.     char            *path;        // Points to path string
  108.     APTR            lister;        // Lister pointer
  109.     ULONG            flags;        // Flags
  110. };
  111.  
  112.  
  113. /****************************************************************************
  114.  
  115.  Packets used to send commands
  116.  
  117.  ****************************************************************************/
  118.  
  119. // EXTCMD_END_ENTRY
  120. struct endentry_packet
  121. {
  122.     struct function_entry    *entry;        // Entry pointer
  123.     BOOL            deselect;    // TRUE to deselect entry
  124. };
  125.  
  126. // EXTCMD_ADD_FILE
  127. struct addfile_packet
  128. {
  129.     char            *path;        // Path to add file to
  130.     struct FileInfoBlock    *fib;        // FileInfoBlock to add
  131.     struct ListerWindow    *lister;    // Lister pointer
  132. };
  133.  
  134. // EXTCMD_DEL_FILE
  135. struct delfile_packet
  136. {
  137.     char            *path;        // Path to delete file from
  138.     char            *name;        // Name of file to delete
  139.     struct ListerWindow    *lister;    // Lister pointer
  140. };
  141.  
  142. // EXTCMD_LOAD_FILE
  143. struct loadfile_packet
  144. {
  145.     char            *path;        // Path of file
  146.     char            *name;        // File name
  147.     short            flags;        // Flags field
  148.     short            reload;        // TRUE to reload existing file
  149. };
  150.  
  151. #define LFF_ICON        (1<<0)
  152.  
  153.  
  154. // EXTCMD_REPLACE_REQ
  155. struct replacereq_packet
  156. {
  157.     struct Window        *window;    // Window to open over
  158.     struct Screen        *screen;    // Screen to open on
  159.     IPCData            *ipc;        // Your process IPC pointer
  160.     struct FileInfoBlock    *file1;        // First file
  161.     struct FileInfoBlock    *file2;        // Second file
  162.     short            flags;        // Flags
  163. };
  164.  
  165. // Result code from EXTCMD_REPLACE_REQ
  166. #define REPLACE_ABORT        -1
  167. #define REPLACE_LEAVE        0
  168. #define REPLACE_REPLACE        1
  169. #define REPLACEF_ALL        (1<<1)
  170.  
  171.  
  172. // EXTCMD_GET_SCREENDATA
  173. struct DOpusScreenData
  174. {
  175.     struct Screen        *screen;    // Screen pointer
  176.     struct DrawInfo        *draw_info;    // DrawInfo pointer
  177.     unsigned short        depth;        // Screen depth
  178.     unsigned short        pen_alloc;    // Mask of allocated pens
  179.     unsigned short        pen_array[16];    // Pen array
  180.     short            pen_count;    // Number of pens
  181. };    
  182.  
  183.  
  184. // EXTCMD_SEND_COMMAND
  185. struct command_packet
  186. {
  187.     char            *command;    // Command to send
  188.     ULONG            flags;        // Command flags
  189.     char            *result;    // Will point to result string
  190.     ULONG            rc;        // Return code
  191. };
  192.  
  193. #define COMMANDF_RESULT        (1<<0)
  194.  
  195.  
  196. // Prototype for the callback hook
  197. ULONG __asm __saveds function_external_hook(
  198.     register __d0 ULONG command,
  199.     register __a0 APTR handle,
  200.     register __a1 APTR packet);
  201.  
  202. #define EXT_FUNC(name)    unsigned long __asm (*name)(register __d0 ULONG,register __a0 APTR,register __a1 APTR)
  203. #define TYPE_EXT(var)    (unsigned long (*)())var
  204.  
  205. #define IDCMP_FUNC(name)    unsigned long __asm (*name)(register __d0 ULONG,register __a0 struct IntuiMessage *)
  206.  
  207.  
  208.  
  209. /**** Define this if you are using the standard modinit.o code ****/
  210. #ifdef _DOPUS_MODULE_DEF
  211.  
  212. // These library bases are defined and made available automatically
  213. extern struct Library *DOSBase;
  214. extern struct Library *DOpusBase;
  215. extern struct Library *IntuitionBase;
  216. extern struct Library *GfxBase;
  217. extern struct Library *IconBase;
  218. extern struct Library *UtilityBase;
  219. extern struct Library *LayersBase;
  220. extern struct Library *GadToolsBase;
  221. extern struct Library *AslBase;
  222. extern struct Library *DiskfontBase;
  223. extern struct Library *RexxSysBase;
  224. extern struct Library *TimerBase;
  225. extern struct Library *LocaleBase;
  226. extern struct Library *WorkbenchBase;
  227.  
  228. // Global pointer to a module's locale information
  229. extern struct DOpusLocale *locale;
  230. void init_locale_data(struct DOpusLocale *);
  231.  
  232. // You MUST define the ModuleInfo structure yourself
  233. extern ModuleInfo module_info;
  234.  
  235. #endif
  236.  
  237. #endif
  238.